/**
 * 
 */

package CCT220_Aula13_Exercicio02_13106;


import java.util.Vector;


/**
 * </br>******************************
 * </br>Project: CCT220
 * </br>Package: CCT220_Aula13_Exercicio02_13106
 * </br>Class: ControleDisciplina
 * </br>Last Change: 05/10/2011 00:00:57
 * </br>Description: Controls the operations for a list of Disciplina and your
 * view
 * </br>******************************</br>
 * 
 * @author marcel
 * @author 13106
 * 
 */
public class ControleDisciplina {
	private final Vector           listaDisciplina = new Vector();
	private final LimiteDisciplina objCLimiteDisc;


	/**
	 * </br>******************************
	 * </br>Constructor for
	 * </br>Package: CCT220_Aula13_Exercicio02_13106
	 * </br>Class: ControleDisciplina
	 * </br>LastChange: 05/10/2011 00:00:50
	 * </br>******************************</br>
	 * 
	 */
	public ControleDisciplina() {

		objCLimiteDisc = new LimiteDisciplina(this);
	}


	/**
	 * </br>******************************
	 * </br>Package: CCT220_Aula13_Exercicio02_13106
	 * </br>Class: ControleDisciplina
	 * </br>Method: insereDisciplina
	 * </br>Last Change: 05/10/2011 00:00:47
	 * </br>Description: Add a new Disciplina to listaDisciplina
	 * </br>******************************</br>
	 * 
	 * @param pCodigo
	 * @param pNome
	 * @param pCargaHoraria
	 */
	public void insereDisciplina(int pCodigo, String pNome, int pCargaHoraria) {

		Disciplina disc = new Disciplina(pCodigo, pNome, pCargaHoraria);
		listaDisciplina.add(disc);
	}


	/**
	 * </br>******************************
	 * </br>Package: CCT220_Aula13_Exercicio02_13106
	 * </br>Class: ControleDisciplina
	 * </br>Method: imprimeDisciplinas
	 * </br>Last Change: 05/10/2011 00:00:45
	 * </br>Description: Get all the Disciplinas String from listaDisciplina
	 * </br>******************************</br>
	 * 
	 * @return the result
	 */
	public String imprimeDisciplinas() {

		String result = "";
		for (int intIdx = 0; intIdx < listaDisciplina.size(); intIdx++) {
			Disciplina objLDisc = (Disciplina) listaDisciplina
			        .elementAt(intIdx);
			result += "Código: " + objLDisc.getCodigo() + " Nome: "
			        + objLDisc.getNome() + " Carga Horaria: "
			        + objLDisc.getCargaHoraria() + "\n";
		}
		return result;
	}


	/**
	 * </br>******************************
	 * </br>Package: CCT220_Aula13_Exercicio02_13106
	 * </br>Class: ControleDisciplina
	 * </br>Method: imprimeDisciplina
	 * </br>Last Change: 05/10/2011 00:00:42
	 * </br>Description: Get the Disciplina String from listaDisciplina
	 * </br>******************************</br>
	 * 
	 * @param pCodigo
	 * @return the result
	 */
	public String imprimeDisciplina(int pCodigo) {

		String result = "";
		for (int intIdx = 0; intIdx < listaDisciplina.size(); intIdx++) {
			Disciplina objLDisc = (Disciplina) listaDisciplina
			        .elementAt(intIdx);
			if (objLDisc.getCodigo() == pCodigo) {
				result = "Código: " + objLDisc.getCodigo() + " Nome: "
				        + objLDisc.getNome() + " Carga Horaria: "
				        + objLDisc.getCargaHoraria();
				break;
			}
		}
		return result;
	}


	/**
	 * </br>******************************
	 * </br>Package: CCT220_Aula13_Exercicio02_13106
	 * </br>Class: ControleDisciplina
	 * </br>Method: main
	 * </br>Last Change: 05/10/2011 00:00:37
	 * </br>Description: Call the constructor of ControleDisciplina();
	 * </br>******************************</br>
	 * 
	 * @param args
	 */
	public static void main(String args[]) {

		new ControleDisciplina();
	}
}
